package routers

import (
	"github.com/astaxie/beego/context"
	"qytest/controllers"
	"github.com/astaxie/beego"
)

func init() {
	beego.InsertFilter("/Manage/*",beego.BeforeRouter,DFunc)

	beego.Router("/login", &controllers.MainController{})
	beego.Router("/logout", &controllers.MainController{},"get:ShowLogout")


	beego.Router("/Manage/user/index", &controllers.MainController{},"get:ShowIndex")
	beego.Router("/Manage/user/addUser",&controllers.MainController{},"get:ShowAdd;post:HandleAdd")
	beego.Router("/Manage/user/delete",&controllers.MainController{},"get:HandleDelete")
	beego.Router("/Manage/user/update",&controllers.MainController{},"get:ShowUpdate;post:HandleUpdate")


}


var DFunc = func(ctx *context.Context) {
	userName := ctx.Input.Session("userName")
	if userName == nil{
		ctx.Redirect(302,"/login")
	}
}